// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Mint from 'mint-ui'
import { Indicator } from 'mint-ui'
import VueResource from 'vue-resource'
import { cookie } from 'vux'
import 'mint-ui/lib/style.css'
import './js/lib/flexble'
import './js/wxtitle/wxtitle'
import filters from './js/filters'
import $ from 'jquery'

window.$ = require("jquery");
Vue.use(VueResource)
Vue.use(Mint)
Vue.config.productionTip = false
Vue.http.options.emulateJSON = true
     
//通过es6的对象新增特性来将filter的属性名导出来，这个是一个数组的形式然后在遍历
Object.keys(filters).forEach(function(key){
    Vue.filter(key, filters[key]); //所有的过滤器全部挂载在全局上面
  });
/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    template: '<App/>',
    components: { App }
})


Vue.http.interceptors.push((request, next) => { //请求拦截器
    //请求前
    request.headers.set('token', cookie.get('token')); //设置请求头
    Indicator.open('加载中...'); //请求loading
    next((response) => {
        //请求后 
        Indicator.close(); //隐藏loading
        return response
    })
})